part of 'component.dart';

Widget searchBar({
  required String hintText,
  TextEditingController? controller,
  VoidCallback? onTap,
  Function(String)? onChanged,
  VoidCallback? onEditingComplete,
  Function(String)? onSubmitted,
  TextStyle? hintStyle,
  TextStyle? labelStyle,
  Alignment alignment = Alignment.center,
  double? height,
  Color? iconColor,
  Color? borderColor,
  Color? focusBorderColor,
  Color? backgroundColor,
  FocusNode? focusNode,
  BorderRadius? borderRadius,
}) {
  var height0 = height ?? 32.r;
  var backgroundColor0 = backgroundColor ?? const Color(0xcc397f58);
  return Container(
    constraints: BoxConstraints(minHeight: height0, maxHeight: height0),
    alignment: alignment,
    child: TextField(
      controller: controller,
      focusNode: focusNode,
      onTap: onTap,
      onChanged: onChanged,
      scrollPadding: EdgeInsets.zero,
      onEditingComplete: onEditingComplete,
      onSubmitted: onSubmitted,
      textAlignVertical: TextAlignVertical.center,
      decoration: InputDecoration(
          enabledBorder: OutlineInputBorder(
              borderSide: BorderSide(
                  color: borderColor ?? backgroundColor0,
                  width: borderColor == null ? 0 : 1),
              borderRadius: borderRadius ?? BorderRadius.circular(height0 / 2)),
          focusedBorder: OutlineInputBorder(
              borderSide: BorderSide(
                  color: borderColor ?? backgroundColor0,
                  width: borderColor == null ? 0 : 1),
              borderRadius: borderRadius ?? BorderRadius.circular(height0 / 2)),
          disabledBorder: OutlineInputBorder(
              borderSide: BorderSide(
                  color: borderColor ?? backgroundColor0,
                  width: borderColor == null ? 0 : 1),
              borderRadius: borderRadius ?? BorderRadius.circular(height0 / 2)),
          prefixIcon: Icon(
            Icons.search,
            size: 15.r,
            color: iconColor ?? const Color(0xfffcfefe),
          ),
          // isCollapsed: true,
          filled: true,
          fillColor: backgroundColor ?? const Color(0xcc397f58),
          contentPadding: EdgeInsets.zero,
          border: InputBorder.none,
          labelStyle: labelStyle ??
              TextStyle(fontSize: 15.sp, color: const Color(0xffffffff)),
          hintText: hintText,
          hintStyle: hintStyle ??
              TextStyle(fontSize: 15.sp, color: const Color(0x66ffffff))),
    ),
  );
}

// Widget searchFadeBar(
//     {required String hintText,
//     VoidCallback? onTap,
//     TextStyle? hintStyle,
//     double? height,
//     Color? iconColor,
//     Color? backgroundColor,
//     required double width}) {
//   var _height = height ?? 32.w;
//   var _backgroundColor = backgroundColor ?? const Color(0xcc397f58);
//   return OpenContainer(
//       closedColor: _backgroundColor,
//       closedElevation: 0,
//       closedShape: RoundedRectangleBorder(
//           borderRadius: BorderRadius.all(Radius.circular(_height / 2))),
//       closedBuilder: (context, callback) {
//         return Container(
//             height: _height,
//             width: width,
//             alignment: Alignment.center,
//             child: Row(
//               children: [
//                 SizedBox(
//                   width: 10.r,
//                 ),
//                 Icon(
//                   IconUtil.search,
//                   size: 15.w,
//                   color: iconColor ?? const Color(0xfffcfefe),
//                 ),
//                 SizedBox(
//                   width: 10.r,
//                 ),
//                 Text(
//                   hintText,
//                   style: hintStyle ??
//                       pfMediumStyle(
//                           fontSize: font15, color: const Color(0x66ffffff)),
//                 )
//               ],
//             ));
//       },
//       openBuilder: (context, _) {
//         return SearchPage();
//       });
// }
